home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9016 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: kuhub.cc.ukans.edu!anh
  2. From: anh@kuhub.cc.ukans.edu
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Schildt <- Advanced Books
  5. Message-ID: <1996Mar7.162150.115560@kuhub.cc.ukans.edu>
  6. Date: 7 Mar 96 16:21:50 CST
  7. References: <8BA8405.02C70020DE.uuout@sourcebbs.com> <danpop.826121528@rscernix>
  8. Organization: University of Kansas Academic Computing Services
  9.  
  10. Er, so what do you use instead of %d ?
  11.  
  12. Anh
  13.  
  14. In article <danpop.826121528@rscernix>, danpop@mail.cern.ch (Dan Pop) writes:
  15. > In <4he6hb$ahn@solutions.solon.com> seebs@solutions.solon.com (Peter Seebach) writes:
  16. >>In article <danpop.825687663@rscernix>, Dan Pop <danpop@mail.cern.ch> wrote:
  17. >>>Sorry, I can hardly believe that.  Here are two examples (originally
  18. >>>posted by Lawrence Kirby) from page 53 of the _third_ edition of C-TCR:
  19. >>
  20. >>>    float f
  21. >>>    printf("%f ", sizeof f);
  22. >>>    printf("%d", sizeof(int));
  23. >>>
  24. >>>Both mistakes appeared in the second edition of the book, as well, and
  25. >>>they are NOT typos.  Ideally, the author shouldn't be allowed to
  26. >>>publish anything on a topic he is utterly unable to understand.
  27. >>>Unfortunately, the market realities of today are far from ideal :-(
  28. >>
  29. >>I could consider the "%f" a typo; it is when I do it.
  30. > "%f" might be a typo (yet it was preserved between editions, so maybe
  31. > it was not a typo :-) but the missing cast _cannot_ be a typo.
  32. >>The others are
  33. >>stunning; the size_t vs int bug is subtle.
  34. > There is nothing subtle here, for someone who knows C (which rules Schildt
  35. > out :-)  size_t is _guaranteed_ not to be defined as int, so using "%d"
  36. > is plain idiotic.  I could understand a "%u", and qualify the author as
  37. > mildly stupid :-)
  38. >>The sizeof(ptr) bug is idiotic.
  39. > Every single bit as idiotic as "%d" for size_t.  Under special 
  40. > circumstances, both give the "correct" results.  At least, sizeof(ptr)
  41. > doesn't invoke undefined behaviour :-)
  42. > Dan
  43. > --
  44. > Dan Pop
  45. > CERN, CN Division
  46. > Email: danpop@mail.cern.ch 
  47. > Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
  48.